
/*  
 * Copyright 2007 MBARI 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.mbari.timeline.piccolo;

import org.mbari.timeline.model.Event;

import edu.umd.cs.piccolo.PNode;

/** 
 * @author Andrew Chase
 */
@SuppressWarnings("serial")
public class EventNode extends PNode{
	private final Event event;
	private final Timeline timeline;
	public static final int HEIGHT = 150;
	
	public EventNode(Event event, Timeline timeline){
		super();
		this.event = event;
		this.timeline = timeline;
	}

	
    /**
     * Use the current x position of the events lines (start, event and end) to compute new time
     * values for those values.
     */
    public void syncTimeToXCoord(){
        event.setTime(timeline.xCoordinateToDate(this.getOffset().getX()));
    }

    /**
     * Use the current time values that correspond to the lines to set the x position of the lines.
     */
    public void syncXCoordToTime(){
        double x = timeline.dateToXCoordinate(event.getTime());
        this.setOffset(x, 0);
    }

	public Event getEvent() {
		return event;
	}
}
